package com.mao.crowd.mvc.controller;

import com.mao.crowd.service.api.AdminService;
import com.mao.crowd.util.CrowdUtil;
import entity.Admin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author maomeng
 * @create 2021-05-27- 11:51
 */
@Controller
public class TestController {

    @Autowired
    private AdminService adminService;

//    页面通过RequestMapping跳转controller方法
//    controller中自动装配service，实现前后端串联
    @RequestMapping("/test/ssm.html")
    public String testssm(ModelMap modelMap, HttpServletRequest request){
        List<Admin> all = adminService.getAll();
        modelMap.addAttribute("adminList",all);
        System.out.println(10/0);
        return "success";
//        success页面在WEB-INF下，符合视图解析器配置
//        如果需要重定向到不在WEB-INF下的index页面，则可以用"redirect:"
    }
}
